#ifndef CLOCKWIDGET_H
#define CLOCKWIDGET_H

#include <QWidget>
#include <QPropertyAnimation>
#include "ClockChart.h"
#include <QGraphicsOpacityEffect>
class ClockWidget : public QWidget
{
    Q_OBJECT
public:


    explicit ClockWidget(int radius,QWidget *parent = nullptr);
    virtual ~ClockWidget();
public:
    // 设置时钟半径
    void setRadius(int radius);
    // 设置更新间隔（参数：毫秒）
    void setUpdateInterval(int interval);

    void setTimerMode(ClockChart::TimerMode mode);

    void setThemeColor(ClockChart::ThemeColor theme); // 设置主题颜色
    // 设置倒计时起始时间（以秒为单位）
    void setInitialTime(int seconds);
public slots:
    void onClockStatus(bool isPaused);
protected:
    virtual void mouseMoveEvent(QMouseEvent *event) override;
    virtual void mousePressEvent(QMouseEvent *event) override;
    virtual void mouseReleaseEvent(QMouseEvent * event) override;
    // 鼠标进入事件
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
    virtual void enterEvent(QEnterEvent *event) override;
#else
    virtual void enterEvent(QEvent *event) override;
#endif
    // 鼠标离开事件
    virtual void leaveEvent(QEvent *event) override;
private:
    void InitForm();
    void InitData();
private:
    ClockChart* m_pChart;
    QPushButton *m_closeButton;      // 关闭按钮
    QPropertyAnimation* fadeInAnimation;
    QPropertyAnimation* fadeOutAnimation;

    QGraphicsOpacityEffect *opacityEffect;
    int newRadius;

    bool isDragging;

    QPoint mouse_startPoint;
    QPoint window_top_left_point;
};

#endif // CLOCKWIDGET_H
